<template>
    <div>
        <cjj-table @getlist="getListData" :total="total" :currentPage="currentPage">
            <template #default="tableSlot">
                <el-table
                    v-if="tableSlot.oHeight"
                    :data="tableData"
                    style="width: 100%"
                    :height="tableSlot.oHeight*1"
                    :header-cell-class-name="hdCellClassName" 
                    border
                >
                    <el-table-column type="index" label="序号" align="center" width="70"></el-table-column>
                    <el-table-column
                        prop="sub_time"
                        label="提交时间"
                        width="160"
                        #default="{row}"
                        align="center" 
                    >{{row.create_time*1000|dateFormatter('YYYY-MM-DD hh:mm:ss')}}</el-table-column>
                    
                    <el-table-column prop="member_name" align="center" width="100" label="客户姓名"></el-table-column>
					<el-table-column prop="member_mobile" align="center"  label="客户手机" width="130"></el-table-column>
                    <el-table-column prop="type_name"  label="询价车款名" min-width="200"></el-table-column>
                    <el-table-column prop="series" label="所属车型" align="center"  width="100"></el-table-column>
                    <el-table-column prop="brand" label="所属品牌" align="center"  min-width="150"></el-table-column>
                    <el-table-column prop="reference_price" align="center"  width="100" label="经销商价格"></el-table-column>
                    <el-table-column prop="guide_price" label="厂商指导价" align="center" width="100"></el-table-column>
                    <el-table-column prop="engine" label="发动机参数" align="center" width="180"></el-table-column>
                    <el-table-column prop="is_displace" label="是否置换" align="center"  width="80" #default="{row}">
						{{row.is_displace==="0"?"否":""}}
                        {{row.is_displace==="1"?"是":""}}
					</el-table-column>
                    <el-table-column prop="store_name" label="所属店铺" align="center"  width="150"></el-table-column>
                </el-table>
            </template>
            <template #button>
                <el-button type="primary" @click="exportData">导出</el-button>
            </template>
        </cjj-table>
    </div>
</template>
<script>
import { dateFormatter } from '@/common/js/util.js'
import { inquiry } from '../api'
import cjjTable from '@/components/home/CjjTable'
export default ({
	props: {
        externalData: { // 注意此属性不要删除，当此组件被单独引入第三方组件时候的父组件传值属性
			type: Object,
			default: null
		} 
	},
    components: { cjjTable },
    data() {
        return {
            abc: 5,
            tableData: [],
            total: 0,
            currentPage: 1,
            pageSize: 20,
            originate: '',
            filter_not_yt: null
        }
    },
    created() {
		if(this.externalData && this.externalData.filter_not_yt) {
			this.originate = this.externalData.originate;
            this.filter_not_yt = this.externalData.filter_not_yt
		}
        this.getListData()
    },
    methods: {
        exportData() {
            let origin = this.$store.state.location.origin;
            window.location.href = origin + "/admin/yt_car/index.php?act=yt_car&op=getCustomerInquiry&form_submit=1"
        },
        async getListData(currentPage = 1, pageSize = localStorage.getItem('pageSize') * 1 || 10) {
            let data = {
                curpage: currentPage,
                pagesize: pageSize,
                originate: this.originate
            }
            if(this.filter_not_yt) data.filter_not_yt = this.filter_not_yt
            let res = await inquiry.getCustomerInquiry(data);
            this.tableData = res.data.list;
            this.total = res.data.TotalNum * 1;
        },
        hdCellClassName() {
            return 'hdCellStyle'
        }
    },
    mounted() {
    }

})
</script>